package com.student.liu.controller;

import com.student.liu.entity.UserCollect;
import com.student.liu.entity.UserReceiveraddress;
import com.student.liu.service.IUserCollectService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("collect")
public class UserCollectController extends BaseController{

    @Resource
    IUserCollectService userCollectService;


    @PostMapping("addGoodsAddress")
    public Object create(@Valid @RequestBody UserCollect userCollect) {
        Integer userId = Integer.parseInt(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString());
        userCollect.setUserId(userId);
        userCollectService.addGoodsAddress(userCollect);
        return success("信息收集成功", null);
    }

}
